package com.hqw.mindanews;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import cn.bmob.v3.Bmob;

import com.hqw.mindanews.application.SysApplication;
import com.hqw.mindanews.fragment.LeftFragment;
import com.hqw.mindanews.fragment.RightFragment;
import com.hqw.mindanews.fragment.SettingFragment;
import com.hqw.mindanews.fragment.ViewPageFragment;
import com.hqw.mindanews.utils.Constant;
import com.hqw.mindanews.view.SlidingMenu;


public class MainActivity extends FragmentActivity   implements OnClickListener{
   
	SlidingMenu mSlidingMenu;
	LeftFragment leftFragment;
	RightFragment rightFragment;
	ViewPageFragment viewPageFragment;
	SettingFragment settingFragment;
  
	ImageView imageView;
	
	@Override
	protected void onCreate(Bundle arg0) {
		// TODO Auto-generated method stub
		super.onCreate(arg0);
		setContentView(R.layout.activity_main);
		Bmob.initialize(this, Constant.BMOB_APP_ID);
		//mSlidingMenu = new SlidingMenu(this);
		init();
		SysApplication.getInstance().addActivity(this);
	}

	private void init() {
		
		mSlidingMenu = (SlidingMenu) findViewById(R.id.slidingMenu);
		mSlidingMenu.setLeftView(getLayoutInflater().inflate(
				R.layout.left_frame, null));
		mSlidingMenu.setRightView(getLayoutInflater().inflate(
				R.layout.right_frame, null));
		mSlidingMenu.setCenterView(getLayoutInflater().inflate(
				R.layout.center_frame, null));
		mSlidingMenu.setCanSliding(false,false);
//		mSlidingMenu.setMode(SlidingMenu.LEFT_RIGHT);
//		mSlidingMenu.setBehindOffset(300);
//		mSlidingMenu.setBehindWidth(200);
//		mSlidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
	FragmentTransaction t = this.getSupportFragmentManager()
				.beginTransaction();
		leftFragment = new LeftFragment();
		t.replace(R.id.left_frame, leftFragment);
			
		rightFragment = new RightFragment();
		t.replace(R.id.right_frame, rightFragment);
		viewPageFragment = new ViewPageFragment();
		t.replace(R.id.center_frame, viewPageFragment);
		
	  //  settingFragment = new SettingFragment();
	   // t.replace(R.id.setting_frame, settingFragment);
		  
		t.commit();
		
		
	}



	public void showLeft() {
		mSlidingMenu.showLeftView();
		//mSlidingMenu.showMenu();
	}

	public void showContent() {
		 mSlidingMenu.showCenter();
		 
	}
	
	public void showRight() {
		mSlidingMenu.showRightView();
		
	}

	@Override
	public void onClick(View v) {
		 
		
	}

	 
	
 

}
